home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / etc / init.d / binfmt-support < prev    next >
Text File  |  2009-09-15  |  2KB  |  73 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          binfmt-support
  4. # Required-Start:    $local_fs $remote_fs
  5. # Required-Stop:     $local_fs $remote_fs
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:
  8. # Short-Description: Support for extra binary formats
  9. # Description:       Enable support for extra binary formats using the Linux
  10. #                    kernel's binfmt_misc facility.
  11. ### END INIT INFO
  12.  
  13. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  14. NAME=binfmt-support
  15. DESC="additional executable binary formats"
  16.  
  17. which update-binfmts >/dev/null 2>&1 || exit 0
  18.  
  19. . /lib/lsb/init-functions
  20. [ -r /etc/default/rcS ] && . /etc/default/rcS
  21.  
  22. set -e
  23. CODE=0
  24.  
  25. case "$1" in
  26.   start)
  27.     ADMINDIR=/var/lib/binfmts
  28.     CACHEDIR=/var/cache/binfmts
  29.     fmts="$(cd "$ADMINDIR"; ls)" || exit 0
  30.     [ -z "$fmts" ] && exit 0
  31.     log_daemon_msg "Enabling $DESC" "$NAME"
  32.     PROCDIR=/proc/sys/fs/binfmt_misc
  33.     if [ ! -e "$PROCDIR/register" ]; then
  34.     modprobe -q binfmt_misc
  35.     mount -t binfmt_misc -o nodev,noexec,nosuid binfmt_misc "$PROCDIR"
  36.     fi
  37.     cachefail=0
  38.     for fmt in $fmts; do
  39.     [ -e "$PROCDIR/$fmt" ] && continue
  40.     if [ ! -e "$CACHEDIR/$fmt" ] ||
  41.        ! cat "$CACHEDIR/$fmt" > $PROCDIR/register; then
  42.         cachefail=1
  43.     fi
  44.     CODE=$?
  45.     done
  46.     if [ "$cachefail" = 1 ]; then
  47.     update-binfmts --enable || CODE=$?
  48.     fi
  49.     log_end_msg $CODE
  50.     exit $CODE
  51.     ;;
  52.  
  53.   stop)
  54.     log_daemon_msg "Disabling $DESC" "$NAME"
  55.     update-binfmts --disable || CODE=$?
  56.     log_end_msg $CODE
  57.     exit $CODE
  58.     ;;
  59.  
  60.   restart|force-reload)
  61.     $0 stop
  62.     $0 start
  63.     ;;
  64.  
  65.   *)
  66.     N=/etc/init.d/$NAME
  67.     echo "Usage: $N {start|stop|restart|force-reload}" >&2
  68.     exit 1
  69.     ;;
  70. esac
  71.  
  72. exit 0
  73.